package net.ulrice.mdls.richclient.monitor;

import java.io.IOException;

import net.ulrice.mdls.services.Application;
import net.ulrice.module.ControllerProviderCallback;
import net.ulrice.module.IFController;
import net.ulrice.module.ModuleType;
import net.ulrice.module.exception.ModuleInstantiationException;
import net.ulrice.module.impl.AbstractModule;

public class MonitorModule extends AbstractModule<MonitorController> {

	private Application application;

	public MonitorModule(Application application) {
		super(application.getName(), application.getName(), ModuleType.NormalModule);
		this.application = application;
	}

	@Override
	public void instantiateModule(ControllerProviderCallback<MonitorController> callback, IFController parent) {
		try {
			callback.onControllerReady(new MonitorController(application));
		} catch (IOException e) {
			callback.onFailure(new ModuleInstantiationException("Error initializing monitor", e));
		}
	}
}
